#!/bin/bash

path=`cd "$( dirname ${BASH_SOURCE[0]} )" && pwd`
config=$path/config
bin=$path/bin
yunzai=`cat $config/yunzai.txt`

cd $path

echo "开始安装局部依赖"

cd $yunzai
cnpm install canvas -g
cnpm install puppeteer -g
findConfig(){
	list=`ls $1`
	noPnpmInstall=true #安装完成要上锁，节约时间和空间成本
	noPipInstall=true #安装完成要上锁，节约时间和空间成本
	for i in $list
	do
		
		if [[ "$i" = "node_modules" ]];then
			continue
		elif [ "$i" = "package.json" ] && [ $noPnpmInstall ];then
			echo "正在使用pnpm安装$1/$i"
			cd $1
			pnpm install
			cd $path
			noPnpmInstall=false
		elif [ "$i" = "pyproject.toml" ] && [ $noPipInstall ];then
			echo "正在使用poetry安装$1/$i"
			cd $1
			poetry install
			cd $path
			noPipInstall=false
		elif [ "$i" = "requirements.txt" ] && [ $noPipInstall ];then
			echo "正在使用poetry run pip安装$1/$i"
			cd $1
			poetry run pip install -r requirements.txt -i https://mirrors.bfsu.edu.cn/pypi/web/simple
			cd $path
			noPipInstall=false
		elif [ -d $1/$i ];then
			findConfig $1/$i
		fi
	done
}
findConfig $path/$yunzai
cd $path

echo "安装特殊依赖"
cd $yunzai
pnpm add baidu-aip-sdk -w
pnpm add systeminformation cheerio -w
pnpm add axios -w
pnpm install mysql -w
pnpm install crypto-js -w
cd $path

cd $path/$yunzai/plugins/TRSS-Plugin
poetry run pip install monotonic-align
cd $path











